<?php

namespace JsonLowCode\UI;

use JsonLowCode\Schema;

/**
 * 组件 - DarkModeSwitch 主题切换按钮
 * @method static DarkModeSwitch make() DarkModeSwitch组件
 */
class DarkModeSwitch extends Schema
{
    protected string $componentName = "DarkModeSwitch";

    public function __construct()
    {
        parent::__construct();
        //默认绑定匹配主题模式
        $this->dark("this.store.theme.darkMode", true);
        $this->onUpdateDark("this.store.theme.setDarkMode", true);
    }

    /**
     * 主题模式
     * @param bool|string $bool
     * @return $this
     */
    public function dark(bool|string $bool = true): static
    {
        return $this->prop('dark', $bool);
    }

    /**
     * 设置更新主题
     * @param string $value
     * @return $this
     */
    public function onUpdateDark(string $value): static
    {
        return $this->events("onUpdate:dark",$value);
    }

}
